using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class ConditionSkinItem : SkinItem
{
	public SkinCondition condition;

	public Text conditionText;

	public Text conditionRemaining;

	public GameObject conditionArea;

	private int limit;

	public int Limit
	{
		get
		{
			return limit;
		}
	}

	protected override void Awake()
	{
		base.Awake();
		condition = GameManager.Instance.FidgetStore.fidgetTypes[skinIndex].skinCondition;
		limit = GameManager.Instance.FidgetStore.fidgetTypes[skinIndex].limit;
		conditionText.text = string.Format(SkinCollection.Instance.conditionLabelTexts[condition], limit);
	}

	private void OnEnable()
	{
		if (!base.Opened)
		{
			SkinCondition skinCondition = condition;
			if (skinCondition == SkinCondition.TotalKill)
			{
				conditionRemaining.text = string.Format("{0}/{1}", ScoreManager.TotalKillCount, limit);
			}
			else
			{
				conditionRemaining.gameObject.SetActive(false);
			}
		}
	}

	private void Start()
	{
		if (base.Opened)
		{
			if (base.selected)
			{
				SelectItem();
			}
			else
			{
				DeselectItem();
			}
		}
		else
		{
			conditionArea.SetActive(true);
		}
	}

	public override void SelectItem()
	{
		base.SelectItem();
		conditionArea.SetActive(false);
	}
}
